package com.techwells.taco.utils;

import java.io.File;

import junit.framework.Assert;
import android.os.Environment;


/**
 * SD卡工具
 */
public class SDCardUtil {
	private static final String SDCardRoot = Environment
			.getExternalStorageDirectory() + File.separator;
	public static final String DIR_DOWNLOAD = SDCardRoot + "saike/download/";
	// SD卡状态
	private static String SDStateString = Environment.getExternalStorageState();

	/**
	 * 得到SD卡的路径
	 * 
	 * @return
	 */
	public static String getSDPath() {
		// SD卡根目录
		File sdDir = null;
		// 判断sd卡是否存在
		boolean sdCardExist = SDStateString.equals(
				android.os.Environment.MEDIA_MOUNTED); 
		if (sdCardExist) {
			// 获取跟目录
			sdDir = Environment.getExternalStorageDirectory();
		}else {
			LogUtil.e("SDCardUtil","sd卡不存在");
			Assert.assertEquals(1, 1);
		}
		return sdDir.toString();
	}

	/**
	 * 取得下载目录
	 * 
	 * @return
	 */
	public static String getDownloadPath() {
		return getSDPath() + "/saike/download/";
	}

	/**
	 * 取得app根目录
	 * 
	 * @return
	 */
	public static String getAppRootPath() {
		return getSDPath() + "/saike/";
	}

	/**
	 * 取得图片目录
	 * 
	 * @return
	 */
	public static String getImagePath() {
		return getSDPath() + "/saike/image/";
	}
	
	
	public static String getUploadAvatar(){
		return getSDPath() + "/saike/avatar/";
	}

	
}